package com.fts.fts.fitness_tracking_system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fts.fts.fitness_tracking_system.mapper.UsersMapper;
import com.fts.fts.fitness_tracking_system.mapper.VideoMapper;
import com.fts.fts.fitness_tracking_system.mapper.VideoSegmentMapper;
import com.fts.fts.fitness_tracking_system.pojo.Video;
import com.fts.fts.fitness_tracking_system.pojo.VideoDetailDTO;
import com.fts.fts.fitness_tracking_system.pojo.VideoSegment;
import com.fts.fts.fitness_tracking_system.service.VideoService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {
    @Resource
    private VideoMapper videoMapper;
    @Resource
    private VideoSegmentMapper videoSegmentMapper;

    @Override
    public VideoDetailDTO getVideoDetail(Integer videoId) {
        Video video = videoMapper.selectById(videoId);


        QueryWrapper<VideoSegment> queryWrapper = new QueryWrapper<VideoSegment>()
                .eq("video_Id", videoId)
                .orderByAsc("sort_Order");
        List<VideoSegment> segments = videoSegmentMapper.selectList(queryWrapper);

        return new VideoDetailDTO(video, segments);
    }
}
